﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;

namespace PlaylistParity
{
    public class MainVM : BaseVM
    {
        /// <summary>
        /// The <see cref="ITunesPlaylists" /> property's name.
        /// </summary>
        public const string ITunesPlaylistsPropertyName = "ITunesPlaylists";

        private ObservableCollection<Playlist> _iTunesPlaylists = new ObservableCollection<Playlist>();

        /// <summary>
        /// Gets the ITunesPlaylists property.
        /// TODO Update documentation:
        /// Changes to that property's value raise the PropertyChanged event. 
        /// This property's value is broadcasted by the Messenger's default instance when it changes.
        /// </summary>
        public ObservableCollection<Playlist> ITunesPlaylists
        {
            get
            {
                return _iTunesPlaylists;
            }

            set
            {
                if (_iTunesPlaylists == value)
                {
                    return;
                }

                var oldValue = _iTunesPlaylists;
                _iTunesPlaylists = value;

                // Update bindings, no broadcast
                RaisePropertyChanged(ITunesPlaylistsPropertyName);
            }
        }

        public MainVM()
        {
            ITunesPlaylists = ITunesUtilities.GetPlaylists();
        }
    }
}
